<template>
  <el-container class="home_container">
    <!-- 头部区域 -->
    <!-- <el-header>
      <div class="header_left">
        <img src="../assets/X2/logo.png" alt="">
        <span class="headerBrea">
          {{ form.signatureName }}
        </span>
      </div>
      <div class="header_right">
        <span>{{ userName }}</span>
      </div>
    </el-header> -->
    <el-container>
      <!-- 主体区域 -->
      <el-main>
        <div class="content">
          <!-- <KeepAlive> -->
          <router-view></router-view>
          <!-- </KeepAlive> -->
        </div>
      </el-main>
    </el-container>


    <!-- 悬浮导航菜单 开始-->
    <div class="navBox">
      <el-menu :default-active="activePath" background-color="#fff" text-color="#68728E" active-text-color="#ffd04b"
        unique-opened router mode="horizontal">
        <!-- 一级菜单 -->
        <el-menu-item :index="item.path" v-for="(item, index) in menulist" :key="index" @click="navClick(item)">
          <template slot="title">
            <img :src="item.authName == pathName ? item.imgUrl2 : item.imgUrl">
            <span>{{ item.authName }}</span>
          </template>
        </el-menu-item>
      </el-menu>
    </div>
    <!-- 悬浮导航菜单 结束-->

  </el-container>
</template>

<script>
export default {
  name: 'HomeR',
  data() {
    return {
      userName: "",
      // 侧边菜单是否折叠
      isCollapse: false,
      //   左侧菜单数据
      menulist: [
        {
          authName: '首页',
          path: '/index',
          imgUrl: require('../assets/X2/nav/index.png'),
          imgUrl2: require('../assets/X2/nav/index2.png'),
        },
        {
          authName: '签到',
          path: '/qianDao',
          imgUrl: require('../assets/X2/nav/qiandao.png'),
          imgUrl2: require('../assets/X2/nav/qiandao2.png'),
        },
        // {
        //   authName: '抽奖',
        //   path: '/jiang',
        //   imgUrl: require('../assets/X2/nav/vote.png'),
        //   imgUrl2: require('../assets/X2/nav/vote2.png'),
        // },
        // {
        //   authName: '摇一摇',
        //   path: '/shake',
        //   imgUrl: require('../assets/X2/nav/shake.png'),
        //   imgUrl2: require('../assets/X2/nav/shake2.png'),
        // },
        // {
        //   authName: '留言上墙',
        //   path: '/liuYan',
        //   imgUrl: require('../assets/X2/nav/liuyan.png'),
        //   imgUrl2: require('../assets/X2/nav/liuyan2.png'),
        // },
        // {
        //   authName: '答题',
        //   path: '/answer',
        //   imgUrl: require('../assets/X2/nav/answer.png'),
        //   imgUrl2: require('../assets/X2/nav/answer2.png'),
        // },
        // {
        //   authName: '投票',
        //   path: '/vote',
        //   imgUrl: require('../assets/X2/nav/vote.png'),
        //   imgUrl2: require('../assets/X2/nav/vote2.png'),
        // },
        {
          authName: '照片墙',
          path: '/photoWall',
          imgUrl: require('../assets/X2/nav/liuyan.png'),
          imgUrl2: require('../assets/X2/nav/liuyan2.png'),
        },
        {
          authName: '红包墙',
          path: '/packetWall',
          imgUrl: require('../assets/X2/nav/answer.png'),
          imgUrl2: require('../assets/X2/nav/answer2.png'),
        },
        // {
        //   authName: '相册',
        //   path: '/photo',
        //   imgUrl: require('../assets/X2/nav/photo.png'),
        //   imgUrl2: require('../assets/X2/nav/photo2.png'),
        // },
        // {
        //   authName: '二维码',
        //   path: '/erWM',
        //   imgUrl: require('../assets/X2/nav/er.png'),
        //   imgUrl2: require('../assets/X2/nav/er2.png'),
        // },
        // {
        //   authName: '设置',
        //   path: '/setUp',
        //   imgUrl: require('../assets/X2/nav/setup.png'),
        //   imgUrl2: require('../assets/X2/nav/setup2.png'),
        // },
      ],
      pathName: '',
      //   激活的链接地址
      activePath: sessionStorage.activePath,
      form: {
        signatureName: '诚赉健康科技有限公司'
      },
      systemId: sessionStorage.systemId
    }
  },
  mounted() { },
  methods: {
    navClick(item) {
      window.sessionStorage.setItem('activePath', item.path)
      this.pathName = item.authName
    },

    // 退出按钮 
    exit() {
      this.$confirm('是否退出登录?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        window.sessionStorage.clear()
        this.$router.push('/login')
      }).catch(() => {
        this.$message('已取消退出')
      });


    },
    // 折叠或展开侧边菜单
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    },
    // 保持菜单链接处于激活状态
    saveNavState(activePath) {
      window.sessionStorage.setItem('activePath', activePath)
      console.log(activePath)
    },
  },
  created() {

    if (this.systemId == 2) {
      this.menulist = this.menulist.filter(item => {
        return item.authName != '照片墙'
      })
    }
    // 获取激活的链接的地址
    this.activePath = window.sessionStorage.getItem('activePath')

    setInterval(() => {
      if (localStorage.form != undefined) {
        this.form = JSON.parse(localStorage.form)
      }
    }, 1000);


  },
}
</script>

<style lang='less' scoped>
// 容器
.home_container {
  height: 100vh;

  // 头部区域样式
  .el-header {
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px !important;
    background: #0B1532;
    box-shadow: 0px 1px 7px 1px rgba(94, 94, 95, 0.11);
    border-radius: 5px 5px 0px 0px;

    .header_left {
      margin-left: 18px;
      display: flex;
      align-items: center;
      cursor: pointer;

      img {
        margin-right: 24px;
        width: 56px;
        height: 56px;
      }

      span {
        display: flex;
        align-items: center;
        font-size: 24px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        color: #FFFFFF;
      }
    }
  }

  // 侧边栏区域
  .el-aside {
    box-sizing: border-box;
    padding-top: 20px;
    padding-left: 15px;
    background-color: #fff;

    // 解决菜单栏展开右侧的边框线
    .el-menu {
      border-right: none;
    }
  }

  // 主体区域
  .el-main {
    padding: 0px !important;
    // padding-top: 0px !important;
    // padding-left: 0px;
    background-color: #fff;
  }
}

// 字体图标样式
.iconfont {
  margin-right: 10px;
}

.header_right {
  display: flex;
  align-items: center;

  span {
    margin-right: 13px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #FFFFFF;
  }
}


.el-menu-item {
  // margin-bottom: 9px;
  width: 164px;
  height: 47px;
  line-height: 47px;
  border-radius: 6px;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: bold;
  color: #68728E;
}

//子节点鼠标移入样式
.el-menu-item:hover {
  background-color: RGBA(235, 240, 255, 0.9) !important;
  border-radius: 6px;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: bold !important;
  color: #3E68FF !important;
}

.content {
  box-sizing: border-box;
  width: 100%;
  height: 100vh;
  background-color: #fff;
  // border-radius: 10px;
  overflow-y: scroll;
}

.el-menu-item.is-active {
  background-color: RGBA(235, 240, 255, 0.9) !important;
  border-radius: 6px;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: bold !important;
  color: #3E68FF !important;
  border-bottom: none;
}

::-webkit-scrollbar {
  display: none;
}

.navBox:hover {
  opacity: 1;
}

.navBox {
  position: absolute;
  bottom: 4px;
  display: flex;
  justify-content: center;
  width: 100%;
  height: 30px;
  opacity: 0.08;
  z-index: 20;

  .el-menu--horizontal {
    background: none !important;
  }

  .el-menu {
    background-color: none !important;
  }

  .el-menu-item {
    padding: 0px;
    margin-right: 4px;
    width: 100px;
    height: 30px;
    line-height: 30px;
    border-radius: 6px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #f73434 !important;
    text-align: center;
    border: none;
    background: linear-gradient(0deg, #730003 0%, #9B0208 100%) !important;

    img {
      margin-right: 10px;
      width: 16px;
      height: 16px;
    }
  }

  .el-menu-item.is-active {
    box-sizing: border-box;
    background-color: RGBA(235, 240, 255, 0.1) !important;
    border-radius: 6px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: bold !important;
    color: #ff0000 !important;
  }

  .el-menu.el-menu--horizontal {
    border-bottom: none;
  }
}
</style>